﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="TeamManagement.aspx.cs" Inherits="WebClient.TeamManagement" %>
    <%@ MasterType VirtualPath="~/Site.master" %>

<%@ Register TagPrefix="asp" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <h2>
        Team Management
    </h2>
    
    <asp:UpdatePanel ID="MainPanel" UpdateMode="Conditional" runat="server">
        <ContentTemplate>

        <div id="teamSelection">
        <p>
            Please Select a Team:
            <asp:ComboBox ID="TeamSelect" runat="server" AutoPostBack="true" DropDownStyle="DropDownList"
                CssClass="" OnTextChanged="LoadNewData" onload="TeamSelect_Load" />
        </p>
    </div>

        <asp:Panel ID="TeamManager" runat="server">
            <asp:Panel ID="CreateTeamPanel" runat="server">
                <span class="failureNotification">
                    <asp:Literal ID="ErrorMessage" runat="server"></asp:Literal>
                </span>
                <asp:ValidationSummary ID="WorkgroupValidationSummary" runat="server" CssClass="failureNotification"
                    ValidationGroup="WorkgroupValidationGroup" />
                <asp:Panel ID="createTeamForm" runat="server" >
                <div class="accountInfo">
                    <fieldset class="register">
                        <legend>Edit User Information</legend>
                    <p>
                        <asp:Label ID="WorkgroupNameLabel" runat="server" AssociatedControlID="WorkgroupName">Workgroup Name:</asp:Label>
                        <asp:RequiredFieldValidator ID="WorkgroupNameRequired" runat="server" ControlToValidate="WorkgroupName"
                            CssClass="failureNotification" ErrorMessage="Workgroup Name is required." ToolTip="Workgroup Name is required."
                            ValidationGroup="WorkgroupValidationGroup">*</asp:RequiredFieldValidator>
                    </p>
                    <p>
                        <asp:TextBox ID="WorkgroupName" runat="server" CssClass="textEntry"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="WorkgroupName"
                            CssClass="failureNotification" ErrorMessage="Workgroup name is required."
                            ToolTip="Workgroup name NetID is required." ValidationGroup="WorkgroupValidationGroup">*</asp:RequiredFieldValidator>
                    </p>
                    <p>
                        <asp:Label ID="SupervisorNameLabel" runat="server" AssociatedControlID="WorkgroupSupervisor">Supervisor NetID:</asp:Label>
                    </p>
                    <p>
                        <asp:TextBox ID="WorkgroupSupervisor" runat="server" CssClass="textEntry"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="WorkgroupSupervisorsRequired" runat="server" ControlToValidate="WorkgroupSupervisor"
                            CssClass="failureNotification" ErrorMessage="At least one (1) Workgroup Supervisor NetID is required."
                            ToolTip="At least one (1) Workgroup Supervisor NetID is required." ValidationGroup="WorkgroupValidationGroup">*</asp:RequiredFieldValidator>
                    </p>
                    <p>
                        <asp:Label ID="PayrollNameLabel" runat="server" AssociatedControlID="WorkgroupPayroll">Payroll NetID:</asp:Label>
                    </p>
                    <p>
                        <asp:TextBox ID="WorkgroupPayroll" runat="server" CssClass="textEntry"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="WorkgroupPayrollRequired" runat="server" ControlToValidate="WorkgroupPayroll"
                            CssClass="failureNotification" ErrorMessage="Workgroup Payroll Contact NetID is required."
                            ToolTip="Workgroup Payroll Contact NetID is required." ValidationGroup="WorkgroupValidationGroup">*</asp:RequiredFieldValidator>
                    </p>
                    </fieldset>
                    
                    <p class="submitButton">
                        <asp:Button ID="CreateWorkGroup" runat="server" Text="Create Team"
                            ValidationGroup="WorkgroupValidationGroup" onclick="CreateWorkGroup_Click" 
                            />
                    </p>
                </asp:Panel>
            </asp:Panel>
            <asp:Panel ID="EditTeamPanel" runat="server">
                <asp:Panel ID="addTeamMember" runat="server" Visible="True">
                    <p>
                        <asp:Label ID="NewMemberLabel" runat="server" Text="New Member netID:" AssociatedControlID="NewMemberBox"></asp:Label>
                    </p>
                    <p>
                        <asp:TextBox ID="NewMemberBox" runat="server" CssClass="textEntry" />
                        <asp:RequiredFieldValidator ID="NewMemberRequired" runat="server" ControlToValidate="NewMemberBox"
                            CssClass="failureNotification" ErrorMessage="New Member NetID is required." ToolTip="New Member NetID is required."
                            ValidationGroup="WorkgroupValidationGroup">*</asp:RequiredFieldValidator>
                    </p>
                    <asp:CheckBox ID="newMemberSupervisor" runat="server" Text="Supervisor Permissions" />
                    <p class="submitButton">
                        <asp:Button ID="AddMemberButton" runat="server" CommandName="AddMemberToTeam" Text="Add"
                            ValidationGroup="WorkgroupValidationGroup" 
                            onclick="AddMemberButton_Click" />
                    </p>
                </asp:Panel>
                <h3>Managed Users:</h3>

                <p>
                    &nbsp;</p>

                <asp:GridView ID="TeamMembersGrid" runat="server" AutoGenerateColumns="False" 
                    onrowcommand="TeamMembersGrid_RowCommand" >
                    <Columns>
                        <asp:BoundField HeaderText="NetID" DataField="NetID" />
                        <asp:BoundField HeaderText="University ID" DataField="UniversityID" />
                        <asp:BoundField HeaderText="Email" DataField="Email" />
                        <asp:BoundField HeaderText="Full Name" DataField="FullName" />
                        <asp:ButtonField HeaderText="Remove User" Text="Remove" CommandName="Delete" />
                    </Columns>
                </asp:GridView>
            </asp:Panel>
            </asp:Panel>
            <div id ="errorPanel">
                    <asp:Panel ID="ErrorPanel" runat="server" Visible="False">
                    <asp:TextBox ID="ErrorText" runat="server" Height="155px" Width="328px" 
                            ForeColor="White" TextMode="MultiLine" BackColor="Black"></asp:TextBox>
                        <br />
                    <asp:Button ID="ErrorClose" runat="server" Text="Close" onclick="ErrorClose_Click"></asp:Button>
                    </asp:Panel>
                </div>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
